<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, maximum-scale=1.0, initial-scale=1, user-scalable=0">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>数据处理脚本--清空患者信息</title>
</head>
<body>
<div id="app">
    <form action="" method="post" id="submitForm">
        服务版本：
        <input id="oms_prod" name="mysql_serve" type="radio" data-text="正式OMS" value="oms_prod"><label for="oms_prod">正式OMS</label>
        <input id="oms_test" name="mysql_serve" type="radio" data-text="测试OMS" value="oms_test"><label for="oms_test">测试OMS</label>
        <input id="dps_prod" name="mysql_serve" type="radio" data-text="正式DPS" value="dps_prod"><label for="dps_prod">正式DPS</label>
        <input id="dps_test" name="mysql_serve" type="radio" data-text="测试DPS" value="dps_test"><label for="dps_test">测试DPS</label>
        <br>
        <br>
        患者手机号：<input type="text" name="patient_mobile" value="">
        <br>
        <br>
        <button type="submit" id="submit">确认操作</button>
    </form>
</div>
</body>

<!-- 引入 Vue 和 Vant 的 JS 文件 -->
<script src="{{ asset('js/url.min.js') }}"></script>
<script src="{{ asset('js/jquery.min.js') }}"></script>
<script>
    $(function () {
        $("#submit").click(function(){

            var pwd = prompt("输入执行密码")
            if (pwd == '' || pwd == undefined) {
                alert('请输入执行密码');
                return false
            }

            if ($("input[type='radio']:checked").val() == '' || $("input[type='radio']:checked").val() == undefined) {
                alert('请选择服务版本');
                return false
            }

            if ($("input[name='patient_mobile']").val() == '' || $("input[name='patient_mobile']").val() == undefined) {
                alert('请填写患者手机号');
                return false
            }

            var msg = "确定要清空《"+$("input[type='radio']:checked").data('text')+"》服务器 \r\n手机号为《"+ $("input[name='patient_mobile']").val() +"》的患者信息吗？\r\n此操作不可逆，请再次确认信息"
            if(confirm(msg)){
                $.ajax({
                    type: "POST",
                    url: "/data/patient/del",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    data: {
                        mysql_server: $("input[type='radio']:checked").val(),
                        mobile: $("input[name='patient_mobile']").val(),
                        pwd: pwd
                    },
                    dataType: "json",
                    success: function(data) {
                        if (data.code === 0) {
                            alert("数据处理成功")
                        } else {
                            alert(data.msg)
                        }
                    },
                    error: function(err) {
                        alert('系统错误，请联系技术')
                    }
                })
            }

            return false

        });
    })
</script>
</html>
